package com.multimedia.scala.euler

import scala.annotation.tailrec
import scala.collection.mutable.HashMap
import scala.collection.mutable.Map
import scala.Math
import com.multimedia.scala.Primes

object Asd122 {
    def main(args : Array[String]) : Unit = {
    	var primes = Primes.findSimples(100).toSet

    	def findMultiplications(maxSteps: Int, maxDigit: Int) = {
    		//because number of multiplications is less then power by 1
    		var m = HashMap[Int, Int](1->0, 2->1).withDefault(x=>x-1)
    		var counter = 0;
    		//@tailrec
	    	def next(steps: Int = 1, used: List[Int] = List(1, 2)) {
	    	    if (steps > maxSteps || used.last > maxDigit) return
    		    counter += 1
    		    println(counter)
	    	    if (steps <= m(used.last)) m(used.last) = steps
	    	    else return
	    	    println(used)
	    	    used.map(used.last + _)
	    	    .foreach(x=>{
	    	    	next(steps+1, used:+x)
	    	    })
	    	}

    		next()
    		m//.map(x=>(x._1, x._2-1))
    	}
    	
    	def findMultiplications2(max: Int) = {
    		var m = HashMap[Int, Int](1->0, 2->1).withDefault(x=>x-1)
    		@tailrec
    		def next(digit: Int = 3) {
    		    if (digit > max) return
    		    if (digit%2==0) m(digit) = m(digit/2) + 1
    		    else {
    		        
    		    }
    		    next(digit + 1)
    		}
    		next()
    	    m
    	}

    	//println(Set(1,2,3,4).combinations(2).foreach(_.foreach(print)))
    	//println(findMultiplications(15).map(x=>x._2).sum)
    	//println(primes)
    	println(findMultiplications(15, 200).map(x=>x._2).sum)
    }
}
